package com.example.service;

import com.example.entity.UserAchievement;
import com.example.mapper.UserAchievementMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
帖子业务处理
 */
@Service
public class UserAchievementService {

    @Resource
    private UserAchievementMapper userachievementMapper;

    public void add(UserAchievement userachievement) {
        userachievementMapper.insert(userachievement);
    }

    public void deleteById(Integer id) {
        userachievementMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(UserAchievement userachievement) {
        userachievementMapper.updateById(userachievement);
    }

    public UserAchievement selectById(Integer id) {
        return userachievementMapper.selectById(id);
    }

    public List<UserAchievement> selectAll(UserAchievement userachievement) {
        return userachievementMapper.selectAll(userachievement);
    }

    public PageInfo<UserAchievement> selectPage(UserAchievement userachievement, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<UserAchievement> postList = userachievementMapper.selectAll(userachievement);
        return PageInfo.of(postList);
    }
}
